<?php

/*
* @author ducnhat
* @email ddnhat@gmail.com
* @copyright 2014
*/

class Zenddn_View_Helper_Banner extends Zend_View_Helper_Abstract{
    
    public function banner($position, $count = 1){
        $cache = new Zenddn_System_Cache();
        $cache = $cache->getCache();
        $position_replace = str_ireplace(" ", "_", $position);        
        $cache_id = "banners_{$position_replace}_{$count}";
        
        if(($banners = $cache->load($cache_id)) === false){
            $model = new Default_Model_Banner();
            $banners = $model->getData($position, $count);
            
            $cache->save($banners, $cache_id, array('banner'));
        }
        
        return $banners;
    }
}